//
//  KLMRowItem.swift
//  KLM_GN
//
//  Created by Nic on 2025/2/27.
//

import UIKit

enum RowItemType {
    case normal
    // 设备设置
    case deviceName
    case deviceLocation
    case AIMode//AI模式
    case seatingInduction //入座感应
    case constantIlluminanceMode//恒照度模式
    case sceneMode//情景模式
    case networkInfo
    case help
    case deviceVersion
    case deleteDevice
    
    // 设置
    case personal
    case accountSecurity
    case update
    case appNotify
    case moreLanguage
    case authorization//隐私设置
    case theme
    case about
    case privacyPolicy
    case networkDiagnosis
    case clearCache
    case logout// 退出登录
    // 关于
    case star
    case componentLicense
    case uploadLog
    case appVersion
    case checkVersion
    case servicePhone
    // app 通知
    case timeDND
    case notificationPermissions
    case homeNotify
    case notify
    case deviceDND
    case repetition
    
    // 账号与安全
    case accountLocation
    case mobile
    case email
    case userCode
    case deleteAccount// 注销
    
    // 个人资料
    case icon
    case nickName
    case timeZone
    
    
    // 添加房间
    case addRoom
}

struct KLMRowItem {
    var type: RowItemType
    var title: String? = ""
    var titleColor : UIColor
    var subTitle: String? = ""
    var rightTitle : String? = ""
    var rightImage : String? = ""
    var rightTitleColor : UIColor
    var rightBorder : Bool
    var showSwitch : Bool
    var isOn : Bool
    var onImage : String
    var offImage : String
    var arrowIcon : String
    var showArrow: Bool
    
    // MARK: - 配置初始化
    init(type: RowItemType = .normal, title: String? = nil, subTitle: String? = nil, titleColor: UIColor = rgba(38, 38, 38, 1), rightTitle: String? = nil, rightImage: String? = nil, rightTitleColor: UIColor = rgba(129, 129, 129, 1), showSwitch: Bool = false, rightBorder: Bool = false, isOn: Bool = false, onImage: String = "switch_on", offImage: String = "switch_off", arrowIcon: String = "arrow_right", showArrow: Bool = true) {
        self.type = type
        self.title = title
        self.titleColor = titleColor
        self.subTitle = subTitle
        self.rightTitle = rightTitle
        self.rightImage = rightImage
        self.rightTitleColor = rightTitleColor
        self.rightBorder = rightBorder
        self.showSwitch = showSwitch
        self.isOn = isOn
        self.onImage = onImage
        self.offImage = offImage
        self.arrowIcon = arrowIcon
        self.showArrow = showArrow
    }
    // MARK: - 设备列表 -> 设备设置 页面配置
    static func deviceInfoSettingItems(info: KLMHomeDevice, config: KLMRKDeviceConfig) -> [[KLMRowItem]] {
        return [
            [
                KLMRowItem(type: .deviceName, title: "设备名称", subTitle: info.deviceName),
                KLMRowItem(type: .deviceLocation, title: "设备位置", subTitle: info.roomName),
                KLMRowItem(type: .AIMode, title: "AI模式", subTitle: "灯具根据场景自主选择合适的模式，可自定义", showSwitch: true, isOn: config.isAIMode),
                KLMRowItem(type: .seatingInduction, title: "入座感应", subTitle: "打开之后感应到人自动亮灯，人走自动灯灭", showSwitch: true, isOn: config.isSeatInductionMode, showArrow: false),
                KLMRowItem(type: .constantIlluminanceMode, title: "恒照度模式", subTitle: "固定亮度色温不自动调节灯光亮度", showSwitch: true, isOn: config.isConstantLightMode, showArrow: false),
                KLMRowItem(type: .sceneMode, title: "情景模式", subTitle: "用户可创建自定义模式", showSwitch: true, isOn: config.isSituationalMode)
                
            ],
            [
                KLMRowItem(type: .networkInfo, title: "网络信息"),
                KLMRowItem(type: .help, title: "使用帮助"),
                KLMRowItem(type: .deviceVersion, title: "固定更新", subTitle: "当前版本\(config.version ?? "未知")")
            ],
            [
                KLMRowItem(type: .deleteDevice, title: "删除设备", titleColor: rgba(244, 57, 57, 1), showArrow: false)
            ],
        ]
    }
    // MARK: - “我的” -> 设置 页面配置
    static func mineSettingItems() -> [[KLMRowItem]] {
        return [
            [
                KLMRowItem(type: .personal, title: "个人资料"),
                KLMRowItem(type: .accountSecurity, title: "账号与安全"),
                KLMRowItem(type: .update, title: "设备升级")
            ],
            [
                KLMRowItem(type: .appNotify, title: "APP消息通知"),
                KLMRowItem(type: .moreLanguage, title: "多语言设置"),
                KLMRowItem(type: .authorization, title: "隐私设置"),
                KLMRowItem(type: .theme, title: "主题模式")
            ],
            [
                KLMRowItem(type: .about, title: "关于"),
                KLMRowItem(type: .privacyPolicy, title: "隐私政策管理")
            ],
            [
                KLMRowItem(type: .networkDiagnosis, title: "网络诊断"),
                KLMRowItem(type: .clearCache, title: "清理缓存")
            ],
            [
                KLMRowItem(type: .logout, title: "退出登录", titleColor: rgba(244, 57, 57, 1), showArrow: false)
            ]
        ]
    }
    // MARK: - 设置 -> 关于 页面配置
    static func settingAboutItems() -> [[KLMRowItem]] {
        return [
            [
                KLMRowItem(type: .star, title: "鼓励一下我们"),
                KLMRowItem(type: .componentLicense, title: "开源组件许可"),
                KLMRowItem(type: .uploadLog, title: "上传日志"),
                KLMRowItem(type: .appVersion, title: "当前版本", rightTitle: "6.2.0", showArrow: false),
                KLMRowItem(type: .checkVersion, title: "检查更新")
            ],
            [
                KLMRowItem(type: .servicePhone, title: "客服电话", rightTitle: "400-881-8611", showArrow: false)
            ]
        ]
    }
    // MARK: - 设置 -> 个人资料 页面配置
    static func settingPersonalItems() -> [[KLMRowItem]] {
        return [
            [
                KLMRowItem(type: .icon, title: "头像", rightImage: "appLogo"),
                KLMRowItem(type: .nickName, title: "昵称", rightTitle: "点击设置昵称")
            ],
            [
                KLMRowItem(type: .timeZone, title: "时区", rightTitle: "点击设置时区")
            ]
        ]
    }
    // MARK: - 设置 -> 账号与安全 页面配置
    static func settingAccountItems() -> [[KLMRowItem]] {
        return [
            [
                KLMRowItem(type: .accountLocation, title: "账号所在地", rightTitle: "中国", rightTitleColor: rgba(38, 38, 38, 1), showArrow: false),
                KLMRowItem(type: .mobile, title: "手机号码", subTitle: ""),
                KLMRowItem(type: .email, title: "邮箱", rightTitle: "去绑定", rightTitleColor: rgba(244, 57, 57, 1), rightBorder: true, showArrow: false),
                KLMRowItem(type: .userCode, title: "用户code", rightTitle: "Ax9ruga", rightTitleColor: rgba(38, 38, 38, 1), showArrow: false),
                KLMRowItem(type: .deleteAccount, title: "注销账号")
            ]
        ]
    }
    // MARK: - 设置 -> APP消息通知 页面配置
    static func settingAppNotifyItems() -> [[KLMRowItem]] {
        return [
            [
                KLMRowItem(type: .timeDND, title: "按时段免打扰", rightTitle: "未设置"),
                KLMRowItem(type: .notificationPermissions, title: "访问通知权限", subTitle: "手机通知栏推送", rightTitle: "未设置")
            ],
            [
                KLMRowItem(type: .homeNotify, title: "家庭", subTitle: "仅通过系统通知栏推送", showSwitch: true, showArrow: false),
                KLMRowItem(type: .notify, title: "通知", subTitle: "仅通过系统通知栏推送", showSwitch: true, showArrow: false)
            ]
        ]
    }
    // MARK: - 设置 -> APP消息通知 页面配置
    static func settingAddDNDItems() -> [[KLMRowItem]] {
        return [
            [
                KLMRowItem(type: .deviceDND, title: "免打扰设备", rightTitle: "未设置"),
                KLMRowItem(type: .repetition, title: "重复", rightTitle: "每天")
            ]
        ]
    }
    // MARK: - 设置 -> 多语言设置 页面配置
    static func settingLanguageItems() -> [[KLMRowItem]] {
        return [
            [
                KLMRowItem(title: "简体中文", arrowIcon: "home_check", showArrow: false),
                KLMRowItem(title: "English", arrowIcon: "home_check", showArrow: false)
            ]
        ]
    }
    // MARK: - 设置 -> 主题模式 页面配置
    static func settingThemeItems() -> [[KLMRowItem]] {
        return [
            [
                KLMRowItem(title: "跟随系统", arrowIcon: "home_check", showArrow: false),
                KLMRowItem(title: "普通模式", arrowIcon: "home_check", showArrow: false),
                KLMRowItem(title: "深色模式", arrowIcon: "home_check", showArrow: false)
            ]
        ]
    }
    // MARK: - 设置 -> 隐私政策 页面配置
    static func settingPrivacyItems() -> [[KLMRowItem]] {
        return [
            [
                KLMRowItem(title: "用户隐私政策"),
                KLMRowItem(title: "用户协议 "),
                KLMRowItem(title: "儿童隐私保护声明 "),
                KLMRowItem(title: "第三方信息共享和SDK服务清单 ")
            ]
        ]
    }
    // MARK: - 家庭管理 -> 创建家庭 页面配置
    static func createHomeRooms() -> [KLMRowItem] {
        return [
            KLMRowItem(title: "客房", isOn: true, arrowIcon: "Role_select", showArrow: true),
            KLMRowItem(title: "主卧", isOn: true, arrowIcon: "Role_select", showArrow: true),
            KLMRowItem(title: "次卧", isOn: true, arrowIcon: "Role_select", showArrow: true),
            KLMRowItem(title: "餐厅", isOn: true, arrowIcon: "Role_select", showArrow: true),
            KLMRowItem(title: "书房", isOn: true, arrowIcon: "Role_select", showArrow: true),
            
            KLMRowItem(type: .addRoom, title: "添加其他房间", titleColor: appMainThemeColor, showArrow: false)
        ]
    }
}
